package com.taoyi.mhouse.binder;
/**
 * created by tempo on 2015/11/15.
 */

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.taoy.recyclebinder.DataBindAdapter;
import com.taoy.recyclebinder.DataBinder;
import com.taoyi.mhouse.R;
import com.taoyi.mhouse.util.UIUtils;

;

public class ShoopingEntryBinder extends DataBinder {
    public ShoopingEntryBinder(DataBindAdapter dataBindAdapter) {
        super(dataBindAdapter);
    }
    @Override
    public RecyclerView.ViewHolder newViewHolder(ViewGroup parent) {
        View v= LayoutInflater.from(UIUtils.getContext()).inflate(R.layout.binder_shopping_entry, parent, false);
        ViewHolder holder = new ViewHolder(v);
        return holder;
    }

    @Override
    public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 1;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ViewHolder(View itemView) {
            super(itemView);
            itemView.findViewById(R.id.btn_shopping_brand).setOnClickListener(this);
            itemView.findViewById(R.id.btn_shopping_flash_sale).setOnClickListener(this);
            itemView.findViewById(R.id.btn_shopping_lucky_draw).setOnClickListener(this);
            itemView.findViewById(R.id.btn_shopping_new_presale).setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            int i=0;
            switch(v.getId()){
                case R.id.btn_shopping_brand:
                    i=3;break;
                case R.id.btn_shopping_flash_sale:
                    i=1;break;
                case R.id.btn_shopping_lucky_draw:
                    i=4;break;
                case R.id.btn_shopping_new_presale:
                    i=2;break;
            }
            Toast.makeText(v.getContext(),"item:"+i,Toast.LENGTH_SHORT).show();
        }
    }
}
